cmake_minimum_required(VERSION 3.1)
cmake_policy(SET CMP0048 NEW)
project(rctlcli VERSION 0.1.0.0)

# openssl
include(${CMAKE_ROOT}/Modules/FindOpenSSL.cmake)
set (EXTRALIB ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY})

# include aux cmake scripts
include("../scripts/Gengetopt.cmake")
ADD_GENGETOPT_FILES(CMDLINE cmdline.ggo)

# lua install dir
set(LUA_INSTALL_APDIR ${LUA_INSTALL_DIR}/rctlcli)

include_directories("${CMAKE_CURRENT_BINARY_DIR}"
	"${PROJECT_BINARY_DIR}"
	"${PROJECT_SOURCE_DIR}/../include/")

set(RCTLCLILIST
cli.c
)

set(LIBLIST
rctl.c
arg.c
bash.c
../lib/api.c
../lib/common.c
../lib/exchange.c
../lib/ssltcp.c
)

# extra libs
find_package(Threads)
set (EXTRALIB ${EXTRALIB} ${CMAKE_THREAD_LIBS_INIT})

# target
add_executable(rctlcli ${CMDLINE} ${RCTLCLILIST} ${LIBLIST} )
target_link_libraries(rctlcli ${EXTRALIB})

add_library(rctl SHARED ${CMDLINE} ${LIBLIST})

# install
install(TARGETS rctlcli DESTINATION bin)
install(TARGETS rctl LIBRARY DESTINATION usr/lib)

# crt
install(FILES wirelesser_ca.crt DESTINATION /etc/ssl/certs/)
